#pragma once

typedef enum{
		EOBJTYPE_WATER=0,
		EOBJTYPE_FOOD=1,
		EOBJTYPE_CREATURE=2
}EOBJTYPE;

typedef enum{
	DIR_LEFT_UP,
	DIR_UP,
	DIR_RIGHT_UP,
	DIR_LEFT,
	DIR_RIGHT,
	DIR_LEFT_DOWN,
	DIR_DOWN,
	DIR_RIGHT_DOWN,
	DIR_NONE,
}DIRECTION;

typedef enum{
		RES_COMMON,
		RES_GOOD,
		RES_BAD,
}RESULT_JUDGMENT;


#define INPUT_SIGNAL_COUNT 3
#define OUTPUT_SIGNAL_COUNT 4

#define NERVUS_MAP_WIDTH 6
#define NERVUS_MAP_DEPTH 8

#define ALL_DIRECTION_COUNT 8

#define NERVUS_ANTENNA_NUM 3

#define MAX_CASE ((int) pow( (float)INPUT_SIGNAL_COUNT , ALL_DIRECTION_COUNT))
#define MAX_RUN_STEP (ALL_DIRECTION_COUNT*2+NERVUS_MAP_WIDTH*NERVUS_MAP_DEPTH)
#define MAX_CASE2 6561

#define NV_DEVIDER 100.0

class Complex
{
public:
    double real;
    double image;
    
    Complex(double r=0, double i=0){real = r, image = i;}

	Complex operator+(const Complex &b)
	{
		Complex c;
		c.real = real + b.real;
		c.image = image + b.image;
		return c;
	};

	Complex operator*(const Complex &b)
	{
		Complex c;
		c.real = real * b.real - image * b.image;
		c.image = image * b.real + real * b.image;
		return c;
	}

	double Model()
	{
		return sqrtf(real * real + image * image);
	}

	Complex Combine(  Complex plus )
	{
		Complex temp = (*this)*plus ;
		temp.real += real;	
		temp.image += image;
		return temp;
	};

	Complex& Combine(  Complex add , Complex plus )
	{
		Complex temp = (*this)*plus ;
		real = (temp.real+add.real);
		image = (temp.image+add.image);
		return *this;
	};

	/*Complex Average( Complex a )
	{
		Complex temp = (*this)+a;
		temp.real /= 2;
		temp.image /= 2;
		return temp;
	}*/

	Complex& Square( void )
	{
		Complex temp = *this;
		real = real * temp.real - image * temp.image;
		image = image * temp.real + real * temp.image;
		if( Model() > 1 )
		{
			real = 0;
			image = 1;
		}
		return *this;
	}
};    

//zero signal
#define CONST_C0 c0(0,0.7)
//excited signal
#define CONST_C1 c1(0,1)
//default nervus value
#define CONST_CN cn(0,0.7)

#define NERVUS_MODEL_LEVEL 0.01

#define NV_EMPTY_VALUE -10000

#ifndef TRACE
#define TRACE printf
#endif

